package com.runen.wnhz.runen.ui.adapter.puadapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.runen.wnhz.runen.R;
import com.runen.wnhz.runen.bean.HotHistorySearchBean.DataBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class HotSearchAdapter extends BaseAdapter {

    private List<String> hotSearch;

    private Context context;

    public HotSearchAdapter(List<String> hotSearch, Context context) {
        this.hotSearch = hotSearch;
        this.context = context;
    }

    @Override
    public int getCount() {
        if(hotSearch == null){
            return 0;
        }else {
            return hotSearch.size();
        }
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        if(convertView == null){
            convertView = View.inflate(context,R.layout.search_item_layout,null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder)convertView.getTag();
        }

        String hotSearchItem = hotSearch.get(position);
        viewHolder.text_search.setText(hotSearchItem);

        return convertView;
    }

    static class ViewHolder{

        TextView text_search;

        public ViewHolder(View convertView) {
            this.text_search = convertView.findViewById(R.id.text_search);
        }
    }
}
